Skip to content

Introduce extensible configuration fetcher SPI for JCasC#2865

Draft
somiljain2006 wants to merge 13 commits into
jenkinsci:masterfrom
somiljain2006:Private-repo
Draft

Introduce extensible configuration fetcher SPI for JCasC#2865
somiljain2006 wants to merge 13 commits into
jenkinsci:masterfrom
somiljain2006:Private-repo

Conversation

@somiljain2006

@somiljain2006 somiljain2006 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #2266

Introduce a pluggable configuration fetcher API that allows Configuration as Code to load YAML from extensible sources while preserving existing behavior. Add default fetchers for local filesystem paths and HTTP/HTTPS URLs, along with a credential-resolution abstraction and a bootstrap environment-variable provider. Refactor configuration loading to use the new fetcher pipeline with managed resource lifecycles, and add unit and integration tests covering fetchers, credential providers, resource cleanup, and end-to-end configuration loading.

Your checklist for this pull request

🚨 Please review the guidelines for contributing to this repository.

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side) and not your master branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or in Jenkins JIRA
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Did you provide a test-case? That demonstrates the feature works or fixes the issue.

@somiljain2006 somiljain2006 requested a review from a team as a code owner July 7, 2026 14:01
@somiljain2006 somiljain2006 marked this pull request as draft July 7, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new Service Provider Interface (SPI) for resolving and fetching JCasC YAML configurations from extensible sources, with default fetchers for local filesystem paths and HTTP(S) URLs, plus lifecycle-managed cleanup via FetchResult/FetchContext. This refactors ConfigurationAsCode to use the new fetch pipeline and adds tests around fetcher behavior and resource cleanup.

Changes:

  • Add CasCConfigFetcher SPI and core fetch pipeline primitives (ResolvedYaml, FetchResult, FetchContext).
  • Refactor ConfigurationAsCode configuration loading to fetch YAML via registered fetchers and manage resource lifecycles.
  • Add unit/integration tests for filesystem and HTTP fetchers and for lifecycle cleanup behavior.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test-harness/src/test/java/io/jenkins/plugins/casc/ConfigurationAsCodeTest.java Updates tests to run with a Jenkins rule where new code requires a Jenkins instance.
plugin/src/test/java/io/jenkins/plugins/casc/fetcher/LocalFileSystemFetcherTest.java Verifies local filesystem fetcher supports/scan behavior.
plugin/src/test/java/io/jenkins/plugins/casc/fetcher/FetchResultTest.java Tests FetchResult close/cleanup semantics.
plugin/src/test/java/io/jenkins/plugins/casc/fetcher/FetchContextTest.java Tests deterministic sorting and cascading closure of results.
plugin/src/test/java/io/jenkins/plugins/casc/fetcher/DefaultHttpFetcherTest.java Verifies HTTP fetcher support, filename derivation, and an integration fetch via embedded server.
plugin/src/test/java/io/jenkins/plugins/casc/fetcher/ConfigFetcherIntegrationTest.java End-to-end wiring test for a custom fetcher extension and cleanup lifecycle.
plugin/src/test/java/io/jenkins/plugins/casc/fetcher/BootstrapEnvVarCredentialResolverTest.java Tests env-var resolver behavior for missing/unsupported types.
plugin/src/main/java/io/jenkins/plugins/casc/yaml/YamlUtils.java Adds support for reading from ResolvedYaml sources.
plugin/src/main/java/io/jenkins/plugins/casc/yaml/YamlSource.java Adds named sources and a factory for ResolvedYaml.
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/ResolvedYaml.java New abstraction for YAML items with an InputStream supplier.
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/LocalFileSystemFetcher.java Default fetcher for files/directories (recursive scan).
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchResult.java Resource + temp-directory cleanup wrapper for fetch results.
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchCredentialsProvider.java Extension point for credential providers.
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchCredentials.java Credential resolution façade (extensions + bootstrap env).
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchContext.java Aggregates sources and ensures results are closed.
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchAuthData.java Credential data model (token/username+password/SSH key).
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/EnvVarFetchCredentialsProvider.java Extension-backed env-var credential provider.
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/DefaultHttpFetcher.java Default fetcher for HTTP(S) single-file YAML sources.
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/CasCConfigFetcher.java SPI contract for config fetchers.
plugin/src/main/java/io/jenkins/plugins/casc/fetcher/BootstrapEnvVarCredentialResolver.java Bootstrap credential resolver from environment variables.
plugin/src/main/java/io/jenkins/plugins/casc/ConfigurationAsCode.java Refactors config loading to use fetchers and managed lifecycles.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugin/src/main/java/io/jenkins/plugins/casc/fetcher/DefaultHttpFetcher.java Outdated
Comment thread plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchCredentials.java Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.

Comment thread plugin/src/main/java/io/jenkins/plugins/casc/fetcher/DefaultHttpFetcher.java Outdated
Comment thread plugin/src/main/java/io/jenkins/plugins/casc/fetcher/DefaultHttpFetcher.java Outdated
@somiljain2006

Copy link
Copy Markdown
Contributor Author

@timja CI is failing during dependency resolution with:

No versions available for junit:junit-dep:jar:[4.9,) within specified range

I reran it and got the same error. Could you please check?

@timja

timja commented Jul 8, 2026

Copy link
Copy Markdown
Member

Maybe this? jenkins-infra/helpdesk#5221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hosting JCasC in a private repository or cloud storage

3 participants